const app = getApp()
Page({
  data: {
    loadingHidden: false,
    isbind:false,
  },
  //失物招领
  foundbtn: function (e) {
    wx.navigateTo({
      url: '../found/found'
    })
  },
  //相册 班图发布
  photobtn: function (e) {
    wx.navigateTo({
      url: '../classcard/classcard'
    })
  },
  onLoad: function (options) {
    if (app.globalData.bindInfo) {
      this.setData({isbind: true });
      this.setData({loadingHidden: true });
    } else {
      this.setData({ loadingHidden: true });
      this.revalidation();
    }
  },

  //重新验证登录 获取用户信息
  revalidation: function () {
    var openid = app.globalData.openid;
    var type = "";
    var that = this;
    wx.request({
      url: app.globalData.baseUrl + 'revalidation',
      method: "POST",
      data: {
        oauth: 'mapp',
        openid: openid,
      },
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (result) {
        that.setData({
          loadingHidden: true
        })
        if (result.data.code == 1) {
          that.setData({
            isbind: true,
          })
        }
        if (result.data.code == 0) {
          wx.redirectTo({
            url: '../binding/binding'
          });
          return;
        }
      }
    })
  },

  onReady: function () {
  },
  onShow: function () {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})